#ifndef INJECT_THREAD_H
#define INJECT_THREAD_H

#include <mutex>
#include <thread>
#include <vector>

struct EmitItem {
    uint16_t type;
    uint16_t code;
    uint32_t value;
};

class InjectThread {
  public:
    InjectThread();
    virtual ~InjectThread();
    void Start();
    void InjectEvent(EmitItem &injectInputEvent) const;
    void Sync();
    void SetDeviceId(int deviceId) {
        deviceId_ = deviceId;
    }

  private:
    static void RunThread(void *param);
    void InjectFunc() const;

  private:
    static std::mutex mutex_;
    static std::condition_variable conditionVariable_;
    static std::vector<EmitItem> injectList_;
    bool isRunning_;
    std::thread thread_;
    int deviceId_;
};

#endif // INJECT_THREAD_H